<div id="top-panel">
    <div id="panel">
        <ul>
            <li><a href="<?php echo site_url("city/create"); ?>" class="report">Create</a></li>            	
        </ul>
    </div>
</div>
<script language="javascript">
	var jq = jQuery.noConflict();
	jq(document).ready(function(){
		jq("#c_id").change(function(){
			var val = jq(this).val();
			if( val !=0 ){
				var url = jq("#form_filter").attr("action");
				document.location=url+"/"+val;
			}
			else{
				window.location = jq('a.hidden-link').attr('href');
			}
		});	
	});
</script>
<div id="wrapper">
	<div id="content">
		<div id="rightnow">
			<h3 class="reallynow">City list</h3>
			<div class="search_wrap">	
				<div style="float:left;">
					<?php echo form_open('city/search', array('class'=>'form_search')) ?>
					Search: <input type="text" name="search_text" id="search_text" class="input" value="<?php echo isset($search_text) ? $search_text : ''; ?>" />
					<?php echo form_close(); ?>
				</div>
				
				<div style="float:left;">
					<?php echo form_open('city/filter', array('class'=>'form_search', 'id'=>'form_filter')) ?>
				Filter by:<select name="c_id" id="c_id" class="input1">
						<option value="0">All</option>
						<?php if(count($country)>0): ?>
						<?php foreach($country as $v): ?>
							<option value="<?php echo $v['iso']; ?>" <?php if(isset($c_id) && $c_id==$v['iso']):?> selected="selected" <?php endif; ?>><?php echo $v['name']; ?></option>
						<?php endforeach; ?>
						<?php endif; ?>
					</select>
					<?php echo form_close(); ?>
				</div>
			</div>
			<?php if (count($city)): ?>
			<table width="100%">
				<thead>
					<tr>
						<th>City</th>	
						<th>Country</th>	
						<th>List districts</th>	
						<th>Task</th>					
					</tr>
				</thead>
				<tbody>
					<?php foreach($city as $v): ?>
					<tr>
						<td><div style="padding-left:5px;"><a class="tool" href="<?php echo site_url("city/edit/".$v['id']); ?>"><?php echo $v['city']; ?></a></div></td>
						<td><div align="center"><?php echo $v['name']; ?></div></td>						
						<td><div align="center"><a class="tool" href="<?php echo site_url("district/filter/".$v['id']); ?>">List</a></div></td>
						<td><div align="center"><a class="tool" href="<?php echo site_url("city/delete/".$v['id']); ?>">Delete</a></div></td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
			<div id="pager">
				<?php echo $this->pagination->create_links(); ?>
			</div>
			<?php else: ?>
				<p>No data to display</p>
			<?php endif; ?>
			<a href="<?php echo site_url('city'); ?>" class="hidden-link" style="display:none;"></a>
		</div>
	</div>
</div>